home *** CD-ROM | disk | FTP | other *** search
- Path: EU.net!sun4nl!xs4all!usenet
- From: martijnl@xs4all.nl (Martijn Lievaart)
- Newsgroups: comp.lang.c++
- Subject: Re: Dynamically initializing static members
- Date: Sun, 24 Mar 1996 11:17:47 GMT
- Organization: XS4ALL, networking for the masses
- Message-ID: <4j3b1d$n3v@news.xs4all.nl>
- References: <4ituc6$c1h@rc1.vub.ac.be>
- NNTP-Posting-Host: mas01-09.dial.xs4all.nl
- X-Newsreader: Forte Free Agent 1.0.82
-
- class MYCLASS {
- static unsigned int Registration_ID
-
- ...
-
- }
- unsigned int MYCLASS::Registration_D = Registrate("MYCLASS");
-
- should do the trick (you where almost there!).
-
- apardon@rc1.vub.ac.be (Antoon Pardon) wrote:
-
- >I am playing with the idea of somekind of classregistration.
-
- >The registration class would provide for a function:
-
- >unsigned int Registrate(const char *name);
-
- >This would keep the name of the function stored somewhere and
- >would return a registration ID.
-
- >The idea would be to include a static int into the class that
- >would store this ID something like this
-
- >class MYCLASS {
- > static unsigned int
- > Registration_ID
-
- > ...
-
- >}
-
- >The problem now is how do I assign this Registration_ID
- >automatically. In Modula 2 you have initialisation code
- >that is called at the start of the program where you might
- >then put code similar to
-
- >MYCLASS::Registration_D = Registrate("MYCLASS");
-
- >Is something similar possible in C++ or do I have to
- >do it in a different way? I looked at the FAQ but
- >couldn't find an answer there.
-
-
- /~~~~~| /~~~~~| /~~~~~~|~~~~~\~~~~~\~~~~|~~~~~| We now return to our
- / |/ |/ | o | o | | +-| regularly scheduled
- / /| /| | /| | ___/ ___/ | +-| flame-throwing
- ../___/.|____/.|___|__/~|___|_|..|__|..|_____|_____|...martijnl@xs4all.nl..
-
-